package com.xiaochong.tir.api.controller;

import com.xc.logclient.utils.LogTrace;
import com.xiaochong.tir.api.service.ExchangeInfoService;
import com.xiaochong.tir.api.util.ApiVersion;
import com.xiaochong.tir.common.data.mapper.ExchangeInfoMapper;
import com.xiaochong.tir.common.data.po.*;
import com.xiaochong.tir.common.data.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 通证指数
 * @author MengXiangDong
 */
@RestController
@Api(value = "通证指数")
@RequestMapping(value =ApiVersion.API_V1_PREFIX+"/exchange")
public class ExchangeController {

	@Autowired
	private ExchangeInfoService exchangeInfoService;

	@Autowired
	private ExchangeInfoMapper exchangeInfoDao;


	/**
	 * 交易所指数
	 */
	@ApiOperation(value = "交易所指数" , notes = "交易所指数(分页参数：pageIndex,pageSize)")
	@PostMapping("exchangeIndex")
	public ApiResultVo<List<ExchangeInfo>> exchangeIndex(@RequestBody ExchangeInfo exchangeInfo){
		LogTrace.info("交易所指数", "开始执行exchangeIndex交易所指数接口，参数:",exchangeInfo.getPageIndex()+","+exchangeInfo.getPageSize());
		ApiResultVo apiResultVo=exchangeInfoService.selectByEntityList(exchangeInfo);
		return apiResultVo;
	}

    /**
     * 首页前8交易所指数
     */
	@ApiOperation(value = "首页前8交易所指数" , notes = "首页前8交易所指数")
	@GetMapping("topExchangeIndex")
	public ApiResultVo<List<ExchangeInfo>> TopexchangeIndex(){
		LogTrace.info("交易所指数", "开始执行topExchangeIndex首页前8交易所指数",null);
        ApiResultVo apiResultVo=exchangeInfoService.selectByEntityTop(new ExchangeInfo());
		return apiResultVo;
	}

	/**
	 * A股上市公司区块链指数
	 */
	@ApiOperation(value = "A股上市公司区块链指数" , notes = "A股上市公司区块链指数（分页参数：pageIndex,pageSize）")
	@PostMapping("aBlockIndex")
	public ApiResultVo<List<ABlockIndexVo>> ABlockIndex(@RequestBody ListedCompanyIndex listedCompanyIndex){
		LogTrace.info("A股上市公司区块链指数", "开始执行conceptCurrencyA股上市公司区块链指数接口，参数:",listedCompanyIndex.getPageIndex()+","+listedCompanyIndex.getPageSize());
	  	ApiResultVo apiResultVo=exchangeInfoService.selectBlockIndex(listedCompanyIndex);
		return apiResultVo;
	}

    /**
     * 首页A股上市公司区块链指数
     */
    @ApiOperation(value = "首页A股上市公司区块链指数" , notes = "首页A股上市公司区块链指数")
	@GetMapping("aBlockIndexTop")
    public ApiResultVo<List<ABlockIndexVo>> ABlockIndexTop(){
		LogTrace.info("首页A股上市公司区块链指数", "开始执行aBlockIndexTop首页A股上市公司区块链指数接口",null);
		ApiResultVo apiResultVo=exchangeInfoService.selectBlockIndexTop();
        return apiResultVo;
    }

	/**
	 * 非上市公司区块链指数
	 */
	@ApiOperation(value = "非上市公司区块链指数" , notes = "非上市公司区块链指数（分页参数：pageIndex,pageSize）")
	@PostMapping("wBlockIndex")
	public ApiResultVo<List<WBlockIndex>> WBlockIndex(@RequestBody NonListedCompanyIndex nonListedCompanyIndex){
		LogTrace.info("非上市公司区块链指数", "开始执行wBlockIndex非上市公司区块链指数接口，参数:",nonListedCompanyIndex.getPageIndex()+","+nonListedCompanyIndex.getPageSize());
		ApiResultVo api=exchangeInfoService.selectWBlockIndex(nonListedCompanyIndex);
		return api;
	}

    /**
     * 首页非上市公司区块链指数
     */
		@ApiOperation(value = "首页非上市公司区块链指数" , notes = "首页非上市公司区块链指数")
	@GetMapping("wBlockIndexTop")
    public ApiResultVo<List<WBlockIndex>> WBlockIndexTop(){
		LogTrace.info("首页非上市公司区块链指数", "开始执行wBlockIndexTop首页非上市公司区块链指数",null);
		ApiResultVo api=exchangeInfoService.selectWBlockIndexTop();
        return api;
    }

    /**
	 * 概念行情
	 */
	@ApiOperation(value = "概念行情" , notes = "概念行情（指数排序sortType=0;24小时成交额度排序sortType=1;平均涨幅sortType=2）")
	@PostMapping("conceptIndex")
	public ApiResultVo<List<ConceptQuotationVo>> conceptIndex(@RequestBody ConceptCategory conceptCategory){
		LogTrace.info("概念行情", "开始执行conceptIndex概念行情接口，参数:",conceptCategory.getSortType()+"");
		Long jStart = System.currentTimeMillis();
		ApiResultVo api=exchangeInfoService.conceptIndex(conceptCategory);
		LogTrace.info("概念行情查询","总耗时",String.valueOf(System.currentTimeMillis()-jStart));
		return api;
	}

	/**
	 * 首页概念行情（15条）
	 */
	@ApiOperation(value = "首页概念行情" , notes = "概念行情（指数排序sortType=0;24小时成交额度排序sortType=1;平均涨幅sortType=2）")
	@PostMapping("conceptIndexTop")
	public ApiResultVo<List<ConceptQuotationVo>> conceptIndexTop(@RequestBody ConceptCategory conceptCategory){
		LogTrace.info("首页概念行情", "开始执行conceptIndexTop首页概念行情接口，参数:",conceptCategory.getSortType()+"");
		Long jStart = System.currentTimeMillis();
		ApiResultVo api=exchangeInfoService.conceptIndex(conceptCategory);
		LogTrace.info("首页概念行情查询","总耗时",String.valueOf(System.currentTimeMillis()-jStart));
		return api;
	}

	/**
	 * 热门概念
	 */
	@ApiOperation(value = "热门概念" , notes = "热门概念")
	@PostMapping("hotConceptIndex")
	public ApiResultVo<List<ConceptQuotationVo>> HotConceptIndex(){
		LogTrace.info("热门概念", "开始执行hotConceptIndex热门概念接口",null);
		ApiResultVo api=exchangeInfoService.hotConceptIndex();
		return api;
	}

	/**
	 * 平台币种
	 */
	@ApiOperation(value = "平台币种" , notes = "平台币种(参数:概念id:id)")
	@PostMapping("conceptCurrency")
	public ApiResultVo<List<ApiConceptSymbolVo>> conceptCurrency(@RequestBody CurrencyInfo currencyInfo){
		LogTrace.info("平台币种", "开始执行conceptCurrency平台币种接口参数概念id:",currencyInfo.getId().toString());
		Long jStart = System.currentTimeMillis();
		ApiResultVo api=exchangeInfoService.conceptCurrency(currencyInfo);
		LogTrace.info("平台币种查询","总耗时",String.valueOf(System.currentTimeMillis()-jStart));
		return api;
	}

//	 * 货币诊断-排行榜
	@ApiOperation(value = "货币诊断-排行榜" , notes = "货币诊断-排行榜")
	@GetMapping("monetarydiagnosisTop")
	public ApiResultVo<List<MoneyDiagnosisTopVo>> monetarydiagnosisTop(){
		LogTrace.info("货币诊断-排行榜", "开始执行monetarydiagnosisTop货币诊断-排行榜列表接口",null);
		Long jStart = System.currentTimeMillis();
		ApiResultVo api=exchangeInfoService.monetarydiagnosisTop();
		LogTrace.info("货币诊断-排行榜查询","总耗时",String.valueOf(System.currentTimeMillis()-jStart));
		return api;
	}

//	  货币诊断排名前5
	@ApiOperation(value = "货币诊断排名前5" , notes = "货币诊断-排行榜前5")
	@GetMapping("monetarydiagnosisTop5")
	public ApiResultVo<List<MoneyDiagnosisTop5Vo>> monetarydiagnosisTop5(){
		LogTrace.info("货币诊断排名前5", "开始执行monetarydiagnosisTop5货币诊断排名前5接口",null);
		Long jStart = System.currentTimeMillis();
		ApiResultVo api=exchangeInfoService.monetarydiagnosisTop5();
		LogTrace.info("货币诊断排名前5查询","总耗时",String.valueOf(System.currentTimeMillis()-jStart));
		return api;
	}

	/**
	 * 涨跌统计
	 */
	@ApiOperation(value = "涨跌统计" , notes = "涨跌统计")
	@GetMapping("fallStatistics")
	public ApiResultVo<List<GraliIntensity>> fallStatistics(){
		LogTrace.info("涨跌统计", "开始执行fallStatistics涨跌统计接口",null);
		Long jStart = System.currentTimeMillis();
		ApiResultVo api=exchangeInfoService.fallStatistics();
		LogTrace.info("涨跌统计查询","总耗时",String.valueOf(System.currentTimeMillis()-jStart));
		return api;
	}

	/**
	 *
	 行业货币分类
	 */
	@ApiOperation(value = "行业货币分类" , notes = "行业货币分类")
	@GetMapping("bottomtechnology")
	public ApiResultVo<List<BottomTechnologyVo>> bottomtechnology(){
		LogTrace.info("行业货币分类", "开始执行bottomtechnology行业货币分类接口",null);
		Long jStart = System.currentTimeMillis();
		ApiResultVo api=exchangeInfoService.bottomtechnology();
		LogTrace.info("行业货币分类查询","总耗时",String.valueOf(System.currentTimeMillis()-jStart));
		return api;
	}

	/**
	 *
	 行业货币分类
	 */
	@ApiOperation(value = "行业货币分类2" , notes = "行业货币分类2")
	@GetMapping("bottomtechnology2")
	public ApiResultVo<List<BottomTechnologyVo>> bottomtechnology2(){
		LogTrace.info("行业货币分类", "开始执行bottomtechnology行业货币分类接口",null);
		Long jStart = System.currentTimeMillis();
		ApiResultVo api=exchangeInfoService.bottomtechnology2();
		LogTrace.info("行业货币分类查询","总耗时",String.valueOf(System.currentTimeMillis()-jStart));
		return api;
	}

	/**
	 * 平台币概念指数
	 */
	@ApiOperation(value = "平台币概念指数" , notes = " 平台币概念指数(参数：id(概念id))")
	@PostMapping("bottomteZhi")
	public ApiResultVo<List<GaiNianZhiShuVo>> bottomteZhi(@RequestBody ConceptCategory conceptCategory){
		LogTrace.info("平台币概念指数","开始执行bottomteZhi平台币概念指数接口，参数概念id:",conceptCategory.getId().toString());
		Long jStart = System.currentTimeMillis();
		ApiResultVo api=exchangeInfoService.bottomteZhi(conceptCategory);
		LogTrace.info("平台币概念指数查询","总耗时",String.valueOf(System.currentTimeMillis()-jStart));
		return api;
	}

	/**
	 * 货币搜索
	 */
	@ApiOperation(value = "货币搜索" , notes = "货币搜索（参数coinNameCn）")
	@PostMapping("currencySea")
	public ApiResultVo<List<currencySeaVo>> currencySea(@RequestBody CurrencyInfo currencyInfo){
		LogTrace.info("货币搜索", "开始执行currencySea货币搜索接口，参数货币中文名称:",currencyInfo.getCoinNameCn());
		ApiResultVo api=exchangeInfoService.currencySea(currencyInfo);
		return api;
	}

	@ApiOperation(value = "添加自选-货币搜索" , notes = "货币搜索（参数coinNameCn）")
	@PostMapping("addSelfSelectCurrencySea")
	public ApiResultVo<List<CurrencyInfoApiPo>> addSelfSelectCurrencySea(@RequestBody ApiCurrencyInfoVo apiCurrencyInfoVo){
		LogTrace.info("添加自选-货币搜索", "开始执行currencySea货币搜索接口，参数货币中文名称:",apiCurrencyInfoVo.getCoinNameCn());
		ApiResultVo api=exchangeInfoService.addSelfSelectCurrencySea(apiCurrencyInfoVo);
		return api;
	}
	@ApiOperation(value = "添加自选-交易对搜索" , notes = "货币搜索（参数coinNameCn）")
	@PostMapping("addSelfSelectPairSea")
	public ApiResultVo<List<ApiTransactionPairSearchVo>> addSelfSelectPairSea(@RequestBody ApiCurrencyInfoVo apiCurrencyInfoVo){
		LogTrace.info("添加自选-交易对搜索", "开始执行currencySea货币搜索接口，参数货币中文名称:",apiCurrencyInfoVo.getCoinNameCn());
		ApiResultVo<List<ApiTransactionPairSearchVo>> api=exchangeInfoService.addSelfSelectPairSea(apiCurrencyInfoVo);
		return api;
	}
	/**
	 * 市场表现
	 */
	@ApiOperation(value = "市场表现" , notes = "市场表现(参数cmcId)")
	@PostMapping("MarketPer")
	public ApiResultVo<List<MarketPerVo>> MarketPer(@RequestBody CurrencyInfo currencyInfo){
		LogTrace.info("市场表现", "开始执行MarketPer市场表现接口，参数cmcId:",currencyInfo.getCmcId());
		Long jStart = System.currentTimeMillis();
		ApiResultVo api=exchangeInfoService.MarketPer(currencyInfo);
		LogTrace.info("市场表现查询","总耗时",String.valueOf(System.currentTimeMillis()-jStart));
		return api;
	}

	/**
	 * 压力支撑
	 */
	@ApiOperation(value = "压力支撑" , notes = "压力支撑(参数cmcId)")
	@PostMapping("PressureSup")
	public ApiResultVo<List<PressureSupVo>> PressureSup(@RequestBody CurrencyInfo currencyInfo){
		LogTrace.info("压力支撑", "开始执行PressureSup压力支撑接口，参数cmcId:",currencyInfo.getCmcId());
		Long jStart = System.currentTimeMillis();
		ApiResultVo api=exchangeInfoService.PressureSup(currencyInfo);
		LogTrace.info("压力支撑查询","总耗时",String.valueOf(System.currentTimeMillis()-jStart));
		return api;
	}

	/**
	 * 多空趋势
	 */
	@ApiOperation(value = "多空趋势" , notes = "多空趋势(参数cmcId)")
	@PostMapping("spaceTrend")
	public ApiResultVo<List<SpaceTrendVo>> spaceTrend(@RequestBody CurrencyInfo currencyInfo){
		LogTrace.info("多空趋势", "开始执行spaceTrend多空趋势接口，参数cmcId:",currencyInfo.getCmcId());
		Long jStart = System.currentTimeMillis();
		ApiResultVo api=exchangeInfoService.spaceTrend(currencyInfo);
		LogTrace.info("多空趋势查询","总耗时",String.valueOf(System.currentTimeMillis()-jStart));
		return api;
	}

	/**
	 * 平均成本
	 */
	@ApiOperation(value = "平均成本" , notes = "平均成本(参数cmcId)")
	@PostMapping("avgCost")
	public ApiResultVo<List<AvgCostVo>> avgCost(@RequestBody CurrencyInfo currencyInfo) {
		LogTrace.info("平均成本", "开始执行avgCost平均成本接口，参数cmcId:",currencyInfo.getCmcId());
		Long jStart = System.currentTimeMillis();
		ApiResultVo api=exchangeInfoService.avgCost(currencyInfo);
		LogTrace.info("平均成本查询","总耗时",String.valueOf(System.currentTimeMillis()-jStart));
		return api;
	}

	/**
	 * 货币搜索唯一性查询
	 */
	@ApiOperation(value = "货币搜索唯一性查询" , notes = "货币搜索唯一性查询（参数coinNameCn）")
	@PostMapping("uniqueness")
	public ApiResultVo<List<AvgCostVo>> uniqueness(@RequestBody CurrencyInfo currencyInfo) {
		Long jStart = System.currentTimeMillis();
		ApiResultVo api=exchangeInfoService.Uniqueness(currencyInfo);
		return api;
	}

}
